﻿using System.Collections.Generic;
using __ts.Core.Service;

/*
 *  author: able
 *  @2012/2/20 16:33:24
 * 
 */
namespace __ts.Core.Api
{
    /// <summary>
    /// 
    /// </summary>
    public interface IoService
    {
        /**
         * Returns the map of all sessions which are currently managed by this service. The key of map is the
         * of the session.
         * 
         * @return the sessions. An empty collection if there's no session.
         */
        IDictionary<string, IoSession> getManagedSessions();

        /**
         * Adds an that listens any events related with this service.
         */
        void addListener(IoServiceListener listener);

        /**
         * Removed an existing that listens any events related with this service.
         */
        void removeListener(IoServiceListener listener);

        /**
         * Returns the handler which will handle all the connections managed by this service.
         */

        IoHandler getHandler();

        /**
         * Sets the handler which will handle all connections managed by this service. The handler can only be set before
         * the service is started.
         */
        void setHandler(IoHandler handler);

        /**
         * Get the list of filters installed on this service
         * 
         * @return
         */
        IoFilter[] getFilters();

        /**
         * Set the list of filters for this service. Must be called before the service is bound/connected
         */
        void setFilters(params IoFilter[] filters);

        /**
         * Returns the default configuration of the new {@link IoSession}s
         * created by this service.
         */
        IoSessionConfig getSessionConfig();

        /**
         * Tells if the service provide some encryption (SSL/TLS)
         * @return <code>true</code> if the service is secured
         */
        bool isSecured();

        /**
         * Set the mode to use, either secured or not secured
         * @param secured The mode to use
         */
        void setSecured(bool secured);

        /**
         * Inject a will be used
         * by the SSLEngine to handle secured connections.<br/>
         * The must have been created and initialized before being injected in
         * the service.<br/>
         * By setting a SSLContext, the service switch to secured.
         * @param sslContext The configured SSLContex.
         */
        //void setSslContext(SSLContext sslContext);

        /**
         * @return The instance stored in the service.
         */
        //SSLContext getSslContext();

    }
}